from ninja import NinjaAPI
from chat.api import user_router, group_router, message_router, chat_router
from extends.http.resp import FailResp

api = NinjaAPI()

api.add_router("/user/", user_router)
api.add_router("/group/", group_router)
api.add_router("/message/", message_router)
api.add_router ("/chat/" , chat_router)


@api.exception_handler(FailResp)
def fail_resp(request, exc):
    return api.create_response(request, {"detail": exc.args[0]}, status=400)